package com.hnevc.thread;

class Bank{
	int sum=0;
	synchronized public void save(int num){
			sum = sum + num;
			System.out.println("账户余额为："+sum);
	}
}
class Customer implements Runnable {
	Bank bank = new Bank();
	public void run() {
		for (int i = 0; i < 3; i++) {
			bank.save(100);	
		}
	}
}

public class SaveMoney {

	public static void main(String[] args) {
		Customer c = new Customer();
		Thread t1 = new Thread(c);
		Thread t2 = new Thread(c);
		t1.start();
		t2.start();
	}	
}
